{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 感知机 \n",
    "\n",
    "二分类模型"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "$f(x) = sign(w*x + b)$\n",
    "\n",
    "损失函数 $L(w, b) = -\\Sigma{y_{i}(w*x_{i} + b)}$\n",
    "\n",
    "---\n",
    "#### 算法\n",
    "\n",
    "随即梯度下降法 Stochastic Gradient Descent\n",
    "\n",
    "随机抽取一个误分类点使其梯度下降。\n",
    "\n",
    "$w = w + \\eta y_{i}x_{i}$\n",
    "\n",
    "$b = b + \\eta y_{i}$\n",
    "\n",
    "当实例点被误分类，即位于分离超平面的错误侧，则调整w, b的值，使分离超平面向该无分类点的一侧移动，直至误分类点被正确分类"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "拿出iris数据集中两个分类的数据和[sepal length，sepal width]作为特征"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "from sklearn.datasets import load_iris\n",
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# load data\n",
    "iris = load_iris()\n",
    "df = pd.DataFrame(iris.data, columns=iris.feature_names)\n",
    "df['label'] = iris.target"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2    50\n",
       "1    50\n",
       "0    50\n",
       "Name: label, dtype: int64"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#\n",
    "df.columns = ['sepal length', 'sepal width', 'petal length', 'petal width', 'label']\n",
    "df.label.value_counts()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.legend.Legend at 0x1861f370d68>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEKCAYAAAD9xUlFAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAH9lJREFUeJzt3X+UXWV97/H312E00xKYCxkVZpIGgWYBgRIYiRCKINJI\nSCFFSmGh3gALLlyquKhxGUsV0QpKBUFWSYNY5MINjTQG5OeiIAjIDycJJhiMQNFmhtwSwkoACZCM\n3/vH3nMyc5gfZ585zzn72efzWmvWnL3Pnj3fZx+Yb/Z+nu/zmLsjIiIC8J5GByAiIvmhpCAiIiVK\nCiIiUqKkICIiJUoKIiJSoqQgIiIlSgoiIlKipCAiIiVKCiIiUrJT6F9gZi1AD9Dn7nPL3jsauB14\nMd21zN0vHe18kyZN8qlTpwaIVESkuFasWPGKu3eMdVzwpABcCDwL7DLC+4+UJ4vRTJ06lZ6enpoE\nJiLSLMzsd5UcF/TxkZl1AScA3w/5e0REpDZC9yl8F/gi8IdRjjnCzFab2T1mdsBwB5jZuWbWY2Y9\nGzduDBKoiIgETApmNhd42d1XjHLYSmCKux8EfA9YPtxB7r7Y3bvdvbujY8xHYiIiUqWQfQqzgBPN\nbA4wAdjFzG52908NHODurw16fbeZ/bOZTXL3VwLGJSJSlW3bttHb28tbb73V6FBGNGHCBLq6umht\nba3q54MlBXdfCCyE0iijLwxOCOn+DwL/7e5uZoeR3LlsChWTiMh49Pb2MnHiRKZOnYqZNTqcd3F3\nNm3aRG9vL3vttVdV56jH6KMhzOw8AHdfBJwCnG9m24GtwGmuVX9EJKfeeuut3CYEADNj9913Zzx9\nr3VJCu7+EPBQ+nrRoP3XAtfWIwaRelu+qo8r7lvHS5u3smd7GwtmT2PejM5GhyXjlNeEMGC88dX9\nTkGkGSxf1cfCZWvYuq0fgL7NW1m4bA2AEoPkmq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yR/TR8xsOskf+vvTP6otwOA5Y5YAuPvPzGyX9A/5ROCHZrYvyZTbrRli+AuSyRO/kG5PAKak\nrx9w9y0AZrYW+BNgEvCwu7+a7v8R8KejnH9Z+n0FMDVDXCKjUlKQwnH331iyTOEc4Btm9gDJjKi/\ncvfDR/qxYba/DvzU3f/KzKYCD2UIw4BPpqtp7dhpNpPkDmFAP9X9fzhwjmp/XmRY6lOQwjGzPYE3\n3f1m4AqSRzLrgA5L1/Q1s1YbugDLQL/DkSQzT24BdmXHtMTzM4ZxH/DZQTN2zhjj+F8AHzWz/2Fm\nOzH0MdXrJHctIsEpKUgRHUjyDP9pkuft33D3d0hm0PyWmf0SeBo4YtDPvGVmq4BFwNnpvm8Dl6X7\ns/5r/Oskj5tWm9mv0u0Rpes8fBN4CngM+C2wJX37VmBB2mG99/BnEKkNzZIqTc/MHgK+4O49DY5j\nZ3d/I71T+DHwA3cvX7hdJCjdKYjkxyXp3c0zwItEuJSkxE93CiIiUqI7BRERKVFSEBGREiUFEREp\nUVIQEZESJQURESlRUhARkZL/D971my+K8xqCAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1861f370da0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(df[:50]['sepal length'], df[:50]['sepal width'], label='0')\n",
    "plt.scatter(df[50:100]['sepal length'], df[50:100]['sepal width'], label='1')\n",
    "plt.xlabel('sepal length')\n",
    "plt.ylabel('sepal width')\n",
    "plt.legend()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "data = np.array(df.iloc[:100, [0, 1, -1]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "X, y = data[:,:-1], data[:,-1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "y = np.array([1 if i == 1 else -1 for i in y])"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Perceptron"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# 数据线性可分，二分类数据\n",
    "# 此处为一元一次线性方程\n",
    "class Model:\n",
    "    def __init__(self):\n",
    "        self.w = np.ones(len(data[0])-1, dtype=np.float32)\n",
    "        self.b = 0\n",
    "        self.l_rate = 0.1\n",
    "        # self.data = data\n",
    "    \n",
    "    def sign(self, x, w, b):\n",
    "        y = np.dot(x, w) + b\n",
    "        return y\n",
    "    \n",
    "    # 随机梯度下降法\n",
    "    def fit(self, X_train, y_train):\n",
    "        is_wrong = False\n",
    "        while not is_wrong:\n",
    "            wrong_count = 0\n",
    "            for d in range(len(X_train)):\n",
    "                X = X_train[d]\n",
    "                y = y_train[d]\n",
    "                if y * self.sign(X, self.w, self.b) <= 0:\n",
    "                    self.w = self.w + self.l_rate*np.dot(y, X)\n",
    "                    self.b = self.b + self.l_rate*y\n",
    "                    wrong_count += 1\n",
    "            if wrong_count == 0:\n",
    "                is_wrong = True\n",
    "        return 'Perceptron Model!'\n",
    "        \n",
    "    def score(self):\n",
    "        pass"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Perceptron Model!'"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "perceptron = Model()\n",
    "perceptron.fit(X, y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.legend.Legend at 0x1861f86eda0>"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEKCAYAAAD9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ocy9jHGBJQUTd6JVx9NE5FsRyRCRa6PbzxKROdGJ7D4omFUy+pf3sxKZ\nuz4jWu2KiPQQkc+jE6x9Vqha1mkM/xSRBdHnD4xuv1lE3hWRmSKyWkSeLPScX4rIquhz/iEiL4jI\neUTmv/lzNL7W0d1/Et1vlYhc6NJbZ0ziVDSbhHIF8J2qXgWRaZVFpCqRSdAGquqOaKIYDdwafU6q\nqp4Zndzun0AnYAVwoarmikhf4FHgxw5jeIDItCS3ikg9YIGIfBR97EygK3AEWCkizwN5wHAi8/Uc\nAD4GvlXVz0RkCjBVVd+JtgcgWVV7iEg/4EGgb0XeKGOKsqRg4tES4CkReYLIl+lcEelE5Iv+w+iX\nahJQeK6YtwBU9VMRqRP9Iq8NvCYibYlMl121HDFcRmQyw99H76cAadHfZ6nqPgARWQa0ABoAc1R1\nd3T7v4HTSjn+u9Gfi4D0csRlTKksKZi4o6qrJLI8YT/gERGZRWQ206Wqem5JTyvm/ihgtqr+SETS\ngU/KEYYAP46uonV8o8g5RM4QCuRRsf+HBceo6PONKZb1KZi4IyKnAlmqOh74M5FLMiuBhhJdt1dE\nqsqJi6wU9DtcQGTGyX1AXY5PR3xzOcP4APhtoVk5u5ax/5dALxE5SUSSOfEy1QEiZy3GeM6SgolH\nnYlcw/+GyPX2R1T1KJFZMp8QkW+Bb4DzCj0nW0S+BsYCv4xuexJ4LLq9vH+NjyJyuWmxiCyN3i9R\ndI2GR4EFwP+ADcC+6MMTgT9EO6xbF38EY9xhs6SahCcinwC/V9WFPsdRS1UPRs8U3gP+qapFF2w3\nxlN2pmBMcDwUPbvJANYT8OUiTXyyMwVjjDHH2JmCMcaYYywpGGOMOcaSgjHGmGMsKRhjjDnGkoIx\nxphjLCkYY4w55v8De0DNF0iy8SgAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1861f4ecba8>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "x_points = np.linspace(4, 7,10)\n",
    "y_ = -(perceptron.w[0]*x_points + perceptron.b)/perceptron.w[1]\n",
    "plt.plot(x_points, y_)\n",
    "\n",
    "plt.plot(data[:50, 0], data[:50, 1], 'bo', color='blue', label='0')\n",
    "plt.plot(data[50:100, 0], data[50:100, 1], 'bo', color='orange', label='1')\n",
    "plt.xlabel('sepal length')\n",
    "plt.ylabel('sepal width')\n",
    "plt.legend()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## scikit-learn Perceptron"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from sklearn.linear_model import Perceptron"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Perceptron(alpha=0.0001, class_weight=None, eta0=1.0, fit_intercept=False,\n",
       "      n_iter=1000, n_jobs=1, penalty=None, random_state=0, shuffle=False,\n",
       "      verbose=0, warm_start=False)"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "clf = Perceptron(fit_intercept=False, n_iter=1000, shuffle=False)\n",
    "clf.fit(X, y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[  74.6 -127.2]]\n"
     ]
    }
   ],
   "source": [
    "# Weights assigned to the features.\n",
    "print(clf.coef_)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[ 0.]\n"
     ]
    }
   ],
   "source": [
    "# 截距 Constants in decision function.\n",
    "print(clf.intercept_)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.legend.Legend at 0x18620bc8358>"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEKCAYAAAD9xUlFAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xl8FfW9//HXh4BCxBWwKjEEgsUFQQFRQAUEq6JVW5dq\n0V7UW4TQ2/bX2mrr7XJrudXuiyzGam8tEavW7brQXpFFFEVANlE0ISAgCqJsRpaEz++PmYRwPMmZ\n5MycWc7n+Xicx8mZTOZ8v2cgn8x85z1fUVWMMcYYgDZhN8AYY0x0WFEwxhjTwIqCMcaYBlYUjDHG\nNLCiYIwxpoEVBWOMMQ2sKBhjjGkQeFEQkQIReV1Enk7zvWEisk1ElriPHwfdHmOMMU1rm4P3+Bbw\nJnBYE99/UVUvyUE7jDHGZBBoURCRIuBiYCLwHT+22blzZy0pKfFjU8YYkzcWLVr0oap2ybRe0EcK\nvwe+DxzazDqDRWQZsAG4RVXfaG6DJSUlLFy40McmGmNM8onIWi/rBTamICKXAJtUdVEzqy0GilW1\nD/An4IkmtjVWRBaKyMLNmzcH0FpjjDEQ7EDzEOBSEVkDPAScJyLTGq+gqttVdaf79bNAOxHpnLoh\nVS1X1QGqOqBLl4xHP8YYY1opsKKgqj9Q1SJVLQGuAV5Q1esaryMix4iIuF8PdNuzJag2GWOMaV4u\nrj46gIiMA1DVqcCVwHgRqQU+Ba7RVtzLe+/evaxfv55du3b521iftW/fnqKiItq1axd2U4wxJi2J\n23wKAwYM0NSB5urqag499FA6deqEe+AROarKli1b2LFjB927dw+7OcaYPCMii1R1QKb1EpFo3rVr\nV6QLAoCI0KlTp8gfzZhoqKiAkhJo08Z5rqgIu0UmX+T89FFQolwQ6sWhjSZ8FRUwdizU1Div1651\nXgOMHh1eu0x+SMSRgjFJcvvt+wtCvZoaZ7kxQbOi4KMZM2bQq1cvevbsyZ133hl2c0xMvftuy5Yb\n46e8LApBnK+tq6tjwoQJPPfcc6xcuZL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dOU/PsP5rwFAROVJE2nLgaaod\nOEctxgTOioJJolNxzuEvwTnf/nNV3YNzl8y7RGQpsAQY3OhndonI68BU4CZ32S+BX7jLW/rX+B04\np5uWicgb7usmuXM0/DewAHgJWANsc7/9EPA9d8C6NP0WjPGH3SXV5D0RmQ3coqoLQ25HR1Xd6R4p\nPA7cr6qpE7YbEyg7UjAmOn7qHt2sAKqJ+HSRJpnsSMEYY0wDO1IwxhjTwIqCMcaYBlYUjDHGNLCi\nYIwxpoEVBWOMMQ2sKBhjjGnw/wH0hIgOhmSQYwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x18620b4c780>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "x_ponits = np.arange(4, 8)\n",
    "y_ = -(clf.coef_[0][0]*x_ponits + clf.intercept_)/clf.coef_[0][1]\n",
    "plt.plot(x_ponits, y_)\n",
    "\n",
    "plt.plot(data[:50, 0], data[:50, 1], 'bo', color='blue', label='0')\n",
    "plt.plot(data[50:100, 0], data[50:100, 1], 'bo', color='orange', label='1')\n",
    "plt.xlabel('sepal length')\n",
    "plt.ylabel('sepal width')\n",
    "plt.legend()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
